package com.hulk.dryad.manage.config;

import com.hulk.dryad.manage.mail.MultiMailProperties;
import com.hulk.dryad.manage.mail.template.MultiMailSendTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author: hulk
 * @date: 2020/7/14
 * 实现多账号，邮箱轮询发送
 */
@Configuration
@EnableConfigurationProperties({MultiMailProperties.class})
@ConditionalOnProperty(name = "multi.mail.enable", havingValue = "true")
public class MultiMailConfig {


	@Lazy
    @Bean
    @ConditionalOnMissingBean(MultiMailSendTemplate.class)
    public MultiMailSendTemplate multiMailSendTemplate(MultiMailProperties multiMailProperties) {
        return new MultiMailSendTemplate(multiMailProperties);
    }




}